package com.yoso.controller;

import com.yoso.domain.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author shizejin
 * @date 2021/12/6
 * @description:
 */
@RestController
public class DateController {
    @GetMapping("/getDate")
    public User getDate(){
        User user = new User();
        user.setName("yoso");
        user.setBirthday(new Date());
        return user;
    }

    @PostMapping("/postDate")
    public User postDate(@RequestBody User user){
        System.out.println(user.getBirthday());
        return user;
    }

    @PostMapping("/postDate2")
    public Date postDate(@DateTimeFormat(pattern = "yyyyMMdd") Date date){
        System.out.println(date);
        return date;
    }
}
